//特殊类型  联合类型
let pp:string|number|true=66
pp="ad"
pp=true

let arr:(string|number)[]=[34,54,"df"]

//字面量
let ppp:"6"="6"
let ppp2:66|45=66
let ppp3:56|string="da"


//
type ooo= string|number|boolean
type ooo2=string
let vv:ooo=45

interface Per{
    name:string,
    age:number
    height?:number
}
//用type定义接口
type pppp2={
    name:string,
    age:number
    height?:number
}
let p:pppp2={
    name:"dgd",
    age:21
}
//interface可以继承extends
interface SubPer extends Per{
    id:number
}
let lll:SubPer={
    name:"js",
    age:23,
    id:1,
    height:181
}

//交叉:&(同时都要有)
type pppp3=pppp2 & {id:number}
let llll:pppp3={
    name:"js",
    age:23,
    id:1
}

//断言 as
let e1:unknown=76;
console.log((e1 as number).toFixed(2))

let kkk:string|number="dsjk"
console.log(kkk.length)

function get1():string|number{
    return "ahsk"
}
let res=get1();
(res as string).length
// if(typeof res==="string"){
//     res.length
// }
